<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> z子算法 </title>
</head>
<body>
    
</body>
<script>

var convert = function(s, numRows) {
    if(s == null || numRows==1 || numRows > s.length) return s;
    var arrS = copyArrS = s.split("");
    var oddArr,evenArr,str = '',len = arrS.length,totalArr = [];
    for(let x = 0; x < len; x++){
        if( x%2 == 0){
            oddArr = copyArrS.splice(0,numRows);
            totalArr.push(oddArr);
        }else{
            evenArr = copyArrS.splice(0,numRows-2);
            totalArr.push(evenArr);
        }; 
        if(copyArrS.length == 0) break; 
    }; 
    // console.log(totalArr);
    // debugger
    for(let i = 0; i<len; i++){
        const childArr = totalArr[i];
        for (let v = 0; v < childArr.length; v++) {
            const nArr = childArr[v];
        }
    }
    function forFun(v = []){
        for (let s = 0; s < v.length; s++) {
            const vi = v[s];
            if(i%2 == 0){
                str += childArr[i];
            }else{
                str += childArr[childArr.length - 1 - i];
            }
        }
    }
    return str;
};
console.log(convert('abcdefghijklmnopqrstuvwxyz',6));

</script>
</html>